/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javamail.sip.util;


/**
 *
 * @author sriram
 */
public enum eSipMethodType {
    NIL(0, ""),
    INVITE(1, "invite"),
    ACK(2, "ack"),
    OPTIONS(3, "options"),
    BYE(4, "bye"),
    MESSAGE(5, "message"),
    CANCEL(6, "cancel"),
    REGISTER(7, "register"),
    INFO(8, "info");
    
    private final int index;
    private final String str;
    
    eSipMethodType(int index, String string) {
        this.index = index;
        this.str = string;
    }
    
    public int toInt() {
        return index;
    }
 
    public String toString() {
        return str;
    }
    
    public static eSipMethodType fromString(String methodName) {
        methodName = methodName.trim().toLowerCase();
        for (eSipMethodType meth : eSipMethodType.values()) {
            if(methodName.equals(meth.toString().trim().toLowerCase()))
                return meth;
        }
        return NIL;
    }
}
